let mockCategoryList = [
  { id: 1, name: '食品', productCount: 10 },
  { id: 2, name: '饮料', productCount: 5 },
  { id: 3, name: '日用品', productCount: 8 },
  { id: 4, name: '电子产品', productCount: 3 },
  { id: 5, name: '服装', productCount: 12 },
  { id: 6, name: '家用电器', productCount: 2 },
  { id: 7, name: '办公用品', productCount: 7 },
  { id: 8, name: '母婴用品', productCount: 4 },
  { id: 9, name: '美妆个护', productCount: 6 },
  { id: 10, name: '汽车用品', productCount: 1 },
  { id: 11, name: '图书音像', productCount: 9 },
  { id: 12, name: '运动户外', productCount: 5 },
  { id: 13, name: '宠物用品', productCount: 2 },
  { id: 14, name: '五金工具', productCount: 3 },
  { id: 15, name: '其他', productCount: 0 }
];

export function getCategories() {
  return new Promise(resolve => {
    setTimeout(() => {
      resolve({
        code: 20000,
        data: mockCategoryList
      });
    }, 300);
  });
}

export function addCategory(data) {
  return new Promise(resolve => {
    setTimeout(() => {
      const newItem = { ...data, id: Date.now(), productCount: data.productCount || 0 };
      mockCategoryList.unshift(newItem);
      resolve({ code: 20000, data: newItem });
    }, 300);
  });
}

export function updateCategory(id, data) {
  return new Promise(resolve => {
    setTimeout(() => {
      mockCategoryList = mockCategoryList.map(item => item.id === id ? { ...item, ...data } : item);
      resolve({ code: 20000, data: { ...data, id } });
    }, 300);
  });
}

export function deleteCategory(id) {
  return new Promise(resolve => {
    setTimeout(() => {
      mockCategoryList = mockCategoryList.filter(item => item.id !== id);
      resolve({ code: 20000 });
    }, 300);
  });
} 